<template>
  <div class="mod-category">
    <h1>三级分类</h1>
    <el-tree
      :data="tree"
      :props="defaultProps"
      node-key="catId"
      @node-click="nodeClick"
      ref="tree">
    </el-tree>
  </div>
</template>

<script>
/* eslint-disable */
export default {
  data() {
    return {
      tree: [],
      defaultProps: {
        children: "children",
        label: "name",
      },
    };
  },
  created: function () {
    console.log("loading product category tree....");
    this.getTree();
  },
  components: {},
  activated() {},
  methods: {
    nodeClick(data,node,component) {
      this.$emit("tree-node-click",data,node,component)
    },
    getTree() {
      this.$http({
        url: this.$http.adornUrl("/product/category/list/tree"),
        method: "get",
      }).then(({ data }) => {
        this.tree = data.data;
        console.log("get data success:", this.tree);
      });
    },
  },
};
</script>
